const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

const jsReg = /\.(js|jsx|ts|tsx)$/;
const swcLoader = 'swc-loader';
const swcConfig = require('./.swcrc.js');
const nodeModulesReg = /node_modules/;

module.exports = {
    mode:"development",
    entry:"./src/index.js",
    output:{
        path:path.join(__dirname,"build"),
        filename:"index.js",
        libraryTarget:"system"
    },
    devtool:"source-map",
    devServer:{
        port:9000,
        historyApiFallback:true,
        contentBase:path.join(__dirname,"build")
    },
    module:{
        rules: [{
            test: jsReg,
            loader: swcLoader,
            options: swcConfig(true),
            exclude: nodeModulesReg
        }]
    },
    plugins:[
        new HtmlWebpackPlugin({
            inject:false,
            template:"./src/index.html"
        })
    ],
    externals:['react',"react-dom","react-router-dom"]
};